home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / POINTERS.SWG / 0022_Pointers.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  1KB  |  49 lines

  1. {
  2. DVE>> What I want to do is to make it point to the next byte in memory,
  3. DVE>> sort of "apointer:=[byte ptr] apointer + 1"
  4. DVE>> Apointer:=ptr(seg(apointer^),Ofs(apointer^) + 1);
  5.  
  6. AGB> That won't work if the pointer is equal to 0FFFFh (Segment must be
  7. AGB> adjusted!). A shorter (and faster?) method of coding this (wrong) way :
  8. AGB> Inc(LongInt(APointer));
  9.  
  10. Oeps, this doesn't work either, especially in the case $ffff ! (unwanted
  11. paragraph increase and in protected mode a RunTime Error 216 "General
  12. protection fault")
  13.  
  14. For non segm. overrides this should work fine: Aptr:=pchar(Aptr)+1;
  15. and if youre planning segments overrides than you should use this:
  16. }
  17.  
  18. function GetDosPtr(Point:Pointer;Offs:Longint):pointer;
  19. assembler;{offs in [$0..$fffff}
  20. asm
  21.         mov     dx,point.word[2]
  22.         mov     cx,offs.word[2]
  23.         mov     bx,offs.word[0]
  24.         add     bx,point.word[0]
  25.         adc     cx,0
  26.         mov     ax,bx
  27.         and     ax,0fh
  28.         shr     cx,1;rcr bx,1
  29.         shr     cx,1;rcr bx,1
  30.         shr     cx,1;rcr bx,1
  31.         shr     cx,1;rcr bx,1
  32.         add     dx,bx
  33. end;
  34.  
  35. {And for protected mode: }
  36.  
  37. function GetPtr(BASE:Pointer;Offs:Longint):Pbyte;
  38. assembler;
  39. asm
  40.         MOV     AX,word ptr [OFFS+2]
  41.         MOV     BX,word ptr [OFFS+0]
  42.         ADD     BX,word ptr [BASE+0]
  43.         ADC     AX,0
  44.         MUL     SelectorInc
  45.         ADD     AX,word ptr [BASE+2]
  46.         MOV     DX,AX
  47.         MOV     AX,BX
  48. end;
  49.